home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / init.d / avahi-daemon < prev    next >
Text File  |  2008-07-27  |  3KB  |  111 lines

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          avahi
  4. # Required-Start:    $remote_fs dbus
  5. # Required-Stop:     $remote_fs dbus
  6. # Should-Start:         $syslog
  7. # Should-Stop:       $syslog
  8. # Default-Start:     2 3 4 5
  9. # Default-Stop:      0 1 6
  10. # Short-Description: Avahi mDNS/DNS-SD Daemon
  11. # Description:       Zeroconf daemon for configuring your network 
  12. #                    automatically
  13. ### END INIT INFO
  14.  
  15. #set -e
  16.  
  17. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  18. DESC="Avahi mDNS/DNS-SD Daemon"
  19. NAME="avahi-daemon"
  20. DAEMON="/usr/sbin/$NAME"
  21. SCRIPTNAME=/etc/init.d/$NAME
  22.  
  23. # Gracefully exit if the package has been removed.
  24. test -x $DAEMON || exit 0
  25.  
  26. . /lib/lsb/init-functions
  27.  
  28. # Include avahi-daemon defaults if available.
  29. test -f /etc/default/avahi-daemon && . /etc/default/avahi-daemon
  30.  
  31. DISABLE_TAG="/var/run/avahi-daemon/disabled-for-unicast-local"
  32.  
  33. if [ -n "$AVAHI_DAEMON_START" ]; then
  34.     log_warning_msg "The AVAHI_DAEMON_START option in /etc/default/$NAME has been deprecated."
  35.     log_warning_msg "Please remove this setting from the configuration file."
  36.     log_warning_msg "To disable the service use a runlevel editor like sysv-rc-conf or bum instead."
  37. fi
  38.  
  39. #
  40. #       Function that starts the daemon/service.
  41. #
  42. d_start() {
  43.     modprobe capability >/dev/null 2>&1 || true
  44.  
  45.     $DAEMON -c && return 0
  46.  
  47.     if [ -e ${DISABLE_TAG} ]; then 
  48.       # Disabled because of the existance of an unicast .local domain
  49.       log_warning_msg "avahi-daemon disabled because there is a unicast .local domain"
  50.       exit 0;
  51.     fi;
  52.  
  53.     $DAEMON -D
  54. }
  55.  
  56. #
  57. #       Function that stops the daemon/service.
  58. #
  59. d_stop() {
  60.     if $DAEMON -c ; then 
  61.        $DAEMON -k 
  62.     fi
  63. }
  64.  
  65. #
  66. #       Function that reload the config file for the daemon/service.
  67. #
  68. d_reload() {
  69.     $DAEMON -c && $DAEMON -r
  70. }
  71.  
  72. #
  73. #       Function that check the status of the daemon/service.
  74. #
  75. d_status() {
  76.     $DAEMON -c && echo "$DESC is running" || echo "$DESC is not running"
  77. }
  78.  
  79. case "$1" in
  80.     start)
  81.         log_daemon_msg "Starting $DESC" "$NAME"
  82.         d_start
  83.         log_end_msg $?
  84.         ;;
  85.     stop)
  86.         log_daemon_msg "Stopping $DESC" "$NAME"
  87.         d_stop
  88.         log_end_msg $?
  89.         ;;
  90.     reload)
  91.         log_daemon_msg "Reloading services for $DESC" "$NAME"
  92.         d_reload
  93.         log_end_msg $?
  94.         ;;
  95.     restart|force-reload)
  96.         log_daemon_msg "Restarting $DESC" "$NAME"
  97.         $DAEMON -c && d_stop
  98.         d_start
  99.         log_end_msg $?
  100.         ;;
  101.     status)
  102.         d_status
  103.     ;;
  104.     *)
  105.         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|reload}" >&2
  106.         exit 1
  107.         ;;
  108. esac
  109.  
  110. exit 0
  111.